package com.candoit.webapps.pricing.bean.adapters;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.model.SelectItem;

import com.candoit.webapps.pricing.model.Unidad;

@ManagedBean(name = "unidadadapter")
@ViewScoped
public class UnidadAdapter extends GenericAdapter {

	@Override
	public List<SelectItem> getItems() {
		if (items == null){
			items = new ArrayList<SelectItem>();
            list = retrieve();
            for (Unidad u: (List<Unidad>) list ){
                items.add(new SelectItem(u, u.getDescripcion())); 
            }
        }
		return items;
	}
	
	@Override
	public String getClase() {
		return "Unidad";
	}

	@Override
	public String getFieldId() {
		return "id";
	}

	@Override
	public GenericConverter getConverter() {
		converter = new UnidadConverter();
		converter.setClase(getClase());
		converter.setFieldId(getFieldId());
		return converter;
	}

}
